#ifndef GIMP_PALETTES

#include <stdlib.h>
#include <iostream>
#include "arg-eval.h"
using namespace std;

// declare parameter format (either "HEXA" or "RGBA" or "OTHR") to
// be passed to plugin by ColorTool.
#ifndef FORMAT
  #define FORMAT "RGBA"
#endif

// not processed by ColorTool; just to prevend errors
#ifndef ARGNUM
  #define ARGNUM 5
#endif


int main(int argc, char *argv[]) {

  int return_value = 0;

  // if no argument is being passed to plugin, return required FORMAT
  if (argc == 1) {
    cout << FORMAT << endl;
    return_value = 0;
  } else if (argc != ARGNUM) {
    // if neither 1 nor ARGNUM arguments are passed abort
    // (make sure to always return 127 on error!)
    return_value = 127;
  } else {
/*
    for ( int i = 1; i < ARGNUM; i++) {
      int j=0;
      while (argv[i][j] != '\0') {
        switch (argv[i][j]) {
          case 48:
          case 49:
          case 50:
          case 51:
          case 52:
          case 53:
          case 54:
          case 55:
          case 56:
          case 57:
            break;
          default:
	    return_value = 127;
            return return_value;
            break;
        }

        // catch infinite loops (that would overflow the conversion to an integer anyway)
        if (j < 7) {
          j++;
        } else {
          return_value = 127;
          return return_value;
        }

      }
    }
*/

  long int R;
  long int G;
  long int B;
  long int A;

  if (isInt(argv[1])) {
    R = atoi(argv[1]);
  } else {
    return_value = 127;
  }
  if (isInt(argv[2])) {
    G = atoi(argv[2]);
  } else {
    return_value = 127;
  }
  if (isInt(argv[3])) {
    B = atoi(argv[3]);
  } else {
    return_value = 127;
  }
  if (isInt(argv[4])) {
    A = atoi(argv[4]);
  } else {
    return_value = 127;
  }
    cout<<R<<endl<<G<<endl<<B<<endl<<A<<endl;

  return return_value;
}
}

#endif
